
%% Overloading operators 

%See Words.m

%Create objects
A=Words('The')
B=Words('Bunny')

%'Add' objects
C=A+B

%See NDigits.m for a skeleton for HW7 problem 1. 

%% Short Intro to Discrete Fourier Transforms (more to follow)

help fft

%The Fourier transform is an integral (here sum) transform. 

%Any vector can be written as a sum of waves
X=rand(10,1)

%Where the strength of each wave is calculated from the forward transform:
Y=fft(X)

%This is our original vector:
Z=ifft(Y)

X-Z %Note errors at numerical precision



%% Forward transform

% For length N input vector x, the DFT is a length N vector X,
%     with elements
%                      N
%        X(k) =       sum  x(n)*exp(-j*2*pi*(k-1)*(n-1)/N), 1 <= k <= N.
%                     n=1
       
% Take a look at the expression multiplying our vector x(n)

k=2
N=20
n=(1:N)

%Note 'j' is the same as 'i'

M=exp(-j*2*pi*(k-1)*(n-1)/N)

figure
plot(n,M)
hold
plot(n,imag(M))
xlabel('n')
ylabel('M=exp(-j*2*pi*(k-1)*(n-1)/N)')
legend('real(M)','imag(M')








